namespace SupermarketSystem.MSSQLData.Migrations
{
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;

    using SupermarketSystem.MySQLModels;
    using SupermarketSystem.MSSQLModels;
    using SupermarketSystem.MSSQLData;

    public sealed class Configuration : DbMigrationsConfiguration<SupermarketSystem.MSSQLData.SupermarketSystemContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = true;
            AutomaticMigrationDataLossAllowed = true;
        }

        protected override void Seed(SupermarketSystem.MSSQLData.SupermarketSystemContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method 
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //

            using (var mySQLModels = new MySQLModels())
            using (var msSQLContext = new SupermarketSystemContext())
            {
                //mySQLModels.Vendors.ToList().ForEach(v =>
                //{
                //    var vendor = new MSSQLModels.Vendor();
                //    vendor.VendorName = v.Name;
                //    msSQLContext.Vendors.Add(vendor);
                //});
                //context.SaveChanges();

                //msSQLContext.Measures.ToList().ForEach(m =>
                //{
                //    var measure = new Measure();
                //    measure.Name = m.Name;
                //    context.Measures.Add(measure);
                //});
                //context.SaveChanges();

                //msSQLContext.Products.ToList().ForEach(p =>
                //{
                //    var product = new Product();
                //    product.Name = p.Name;
                //    context.Products.Add(product);
                //});
                //context.SaveChanges();
            }
        }
    }
}
